package com.platform.modules.demo.controller;

import com.platform.common.utils.ImUtils;
import com.platform.common.utils.RestResponse;
import com.platform.modules.quality.entity.QlyInspectionEntity;
import com.platform.modules.sys.controller.AbstractController;
import com.platform.modules.sys.entity.SysUserEntity;
import com.platform.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("Demo")
@RestController("demo")
public class DemoController extends AbstractController {


    @Autowired
    SysUserService sysUserService;


    @ApiOperation(value = "demo01")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "currPage", value = "当前页", dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "limit", value = "页大小", dataType = "Integer")
    })
    @PostMapping("/page")
    public RestResponse page(@RequestBody QlyInspectionEntity qlyInspectionEntity) {
        return RestResponse.success(getParams(qlyInspectionEntity));
    }


    @ApiOperation(value = "环信注册")
    @PostMapping("/im/register")
    public RestResponse register() {

        List<SysUserEntity> list = sysUserService.list();

        list.forEach(e->{
            ImUtils.users(e.getUserName(),"123456",e.getRealName());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        });
        return RestResponse.success();
    }


}
